br-dionysus 1.7.7 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -13
- package/attributes.json +1 -1
- package/build/doc.config.ts +1 -1
- package/build/lib.config.ts +1 -1
- package/cypress/component/MInputNumber.cy.ts +38 -0
- package/cypress/component/MSelect.cy.ts +46 -0
- package/cypress/component/MSelectV2.cy.ts +46 -0
- package/cypress/e2e/1-getting-started/todo.cy.js +143 -0
- package/cypress/e2e/2-advanced-examples/actions.cy.js +321 -0
- package/cypress/e2e/2-advanced-examples/aliasing.cy.js +39 -0
- package/cypress/e2e/2-advanced-examples/assertions.cy.js +176 -0
- package/cypress/e2e/2-advanced-examples/connectors.cy.js +98 -0
- package/cypress/e2e/2-advanced-examples/cookies.cy.js +118 -0
- package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +185 -0
- package/cypress/e2e/2-advanced-examples/files.cy.js +85 -0
- package/cypress/e2e/2-advanced-examples/location.cy.js +32 -0
- package/cypress/e2e/2-advanced-examples/misc.cy.js +90 -0
- package/cypress/e2e/2-advanced-examples/navigation.cy.js +55 -0
- package/cypress/e2e/2-advanced-examples/network_requests.cy.js +163 -0
- package/cypress/e2e/2-advanced-examples/querying.cy.js +114 -0
- package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +204 -0
- package/cypress/e2e/2-advanced-examples/storage.cy.js +117 -0
- package/cypress/e2e/2-advanced-examples/traversal.cy.js +121 -0
- package/cypress/e2e/2-advanced-examples/utilities.cy.js +107 -0
- package/cypress/e2e/2-advanced-examples/viewport.cy.js +58 -0
- package/cypress/e2e/2-advanced-examples/waiting.cy.js +30 -0
- package/cypress/e2e/2-advanced-examples/window.cy.js +22 -0
- package/cypress/e2e/spec.cy.ts +5 -0
- package/cypress/e2e/toolCheckType.cy.ts +37 -0
- package/cypress/e2e/toolCompareStructures.cy.ts +19 -0
- package/cypress/e2e/toolCreateHash.cy.ts +7 -0
- package/cypress/e2e/toolMoneyFormat.cy.ts +46 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/support/commands.ts +37 -0
- package/cypress/support/component-index.html +12 -0
- package/cypress/support/component.ts +39 -0
- package/cypress/support/e2e.ts +20 -0
- package/cypress/types.d.ts +1 -0
- package/cypress.config.ts +16 -0
- package/dist/br-dionysus.es.js +2774 -2739
- package/dist/br-dionysus.umd.js +7 -7
- package/dist/cypress.config.d.ts +3 -0
- package/dist/index.css +1 -1
- package/dist/packages/MSelectV2/src/MSelectV2.vue.d.ts +8 -2
- package/dist/packages/SkinConfig/src/SkinConfig.vue.d.ts +1 -1
- package/dist/packages/Tool/checkType/checkType.d.ts +7 -0
- package/dist/packages/Tool/compareStructures/compareStructures.d.ts +10 -0
- package/dist/packages/Tool/createHash/createHash.d.ts +7 -0
- package/dist/packages/index.d.ts +6 -2
- package/dist/vite.config.d.ts +2 -0
- package/package.json +7 -3
- package/packages/Hook/useRemainingSpace/demo.vue +0 -1
- package/packages/Hook/useTableConfig/demo.vue +1 -1
- package/packages/MDialog/src/MDialog.vue +2 -8
- package/packages/MInline/src/MInline.vue +1 -11
- package/packages/MInputNumber/src/MInputNumber.vue +3 -5
- package/packages/MSelectV2/docs/demo.vue +1 -1
- package/packages/MSelectV2/src/MSelectV2.vue +10 -6
- package/packages/MTable/src/MTable.vue +2 -2
- package/packages/MTableColumn/src/MTableColumn.vue +49 -6
- package/packages/MTableColumnSet/src/MTableColumnSet.vue +1 -1
- package/packages/SkinConfig/src/SkinConfig.vue +2 -1
- package/packages/SkinConfig/src/useSkin.ts +5 -2
- package/packages/Tool/checkType/README.md +17 -0
- package/packages/Tool/checkType/checkType.ts +14 -0
- package/packages/Tool/compareStructures/README.md +16 -0
- package/packages/Tool/createHash/README.md +7 -0
- package/packages/Tool/moneyFormat/README.md +13 -12
- package/packages/Tool/moneyFormat/moneyFormat.ts +35 -2
- package/packages/index.ts +8 -2
- package/src/cypress-augmentation.d.ts +9 -0
- package/tags.json +1 -1
- package/{build/base.config.ts → vite.config.ts} +3 -3
- package/web-types.json +1 -1
- package/tool/checkType.ts +0 -15
- /package/{tool → packages/Tool/compareStructures}/compareStructures.ts +0 -0
- /package/{tool → packages/Tool/createHash}/createHash.ts +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Traversal', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/commands/traversal')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('.children() - get child DOM elements', () => {
|
|
9
|
+
// https://on.cypress.io/children
|
|
10
|
+
cy.get('.traversal-breadcrumb')
|
|
11
|
+
.children('.active')
|
|
12
|
+
.should('contain', 'Data')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('.closest() - get closest ancestor DOM element', () => {
|
|
16
|
+
// https://on.cypress.io/closest
|
|
17
|
+
cy.get('.traversal-badge')
|
|
18
|
+
.closest('ul')
|
|
19
|
+
.should('have.class', 'list-group')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('.eq() - get a DOM element at a specific index', () => {
|
|
23
|
+
// https://on.cypress.io/eq
|
|
24
|
+
cy.get('.traversal-list>li')
|
|
25
|
+
.eq(1).should('contain', 'siamese')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('.filter() - get DOM elements that match the selector', () => {
|
|
29
|
+
// https://on.cypress.io/filter
|
|
30
|
+
cy.get('.traversal-nav>li')
|
|
31
|
+
.filter('.active').should('contain', 'About')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('.find() - get descendant DOM elements of the selector', () => {
|
|
35
|
+
// https://on.cypress.io/find
|
|
36
|
+
cy.get('.traversal-pagination')
|
|
37
|
+
.find('li').find('a')
|
|
38
|
+
.should('have.length', 7)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('.first() - get first DOM element', () => {
|
|
42
|
+
// https://on.cypress.io/first
|
|
43
|
+
cy.get('.traversal-table td')
|
|
44
|
+
.first().should('contain', '1')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('.last() - get last DOM element', () => {
|
|
48
|
+
// https://on.cypress.io/last
|
|
49
|
+
cy.get('.traversal-buttons .btn')
|
|
50
|
+
.last().should('contain', 'Submit')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('.next() - get next sibling DOM element', () => {
|
|
54
|
+
// https://on.cypress.io/next
|
|
55
|
+
cy.get('.traversal-ul')
|
|
56
|
+
.contains('apples').next().should('contain', 'oranges')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('.nextAll() - get all next sibling DOM elements', () => {
|
|
60
|
+
// https://on.cypress.io/nextall
|
|
61
|
+
cy.get('.traversal-next-all')
|
|
62
|
+
.contains('oranges')
|
|
63
|
+
.nextAll().should('have.length', 3)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('.nextUntil() - get next sibling DOM elements until next el', () => {
|
|
67
|
+
// https://on.cypress.io/nextuntil
|
|
68
|
+
cy.get('#veggies')
|
|
69
|
+
.nextUntil('#nuts').should('have.length', 3)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('.not() - remove DOM elements from set of DOM elements', () => {
|
|
73
|
+
// https://on.cypress.io/not
|
|
74
|
+
cy.get('.traversal-disabled .btn')
|
|
75
|
+
.not('[disabled]').should('not.contain', 'Disabled')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('.parent() - get parent DOM element from DOM elements', () => {
|
|
79
|
+
// https://on.cypress.io/parent
|
|
80
|
+
cy.get('.traversal-mark')
|
|
81
|
+
.parent().should('contain', 'Morbi leo risus')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('.parents() - get parent DOM elements from DOM elements', () => {
|
|
85
|
+
// https://on.cypress.io/parents
|
|
86
|
+
cy.get('.traversal-cite')
|
|
87
|
+
.parents().should('match', 'blockquote')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('.parentsUntil() - get parent DOM elements from DOM elements until el', () => {
|
|
91
|
+
// https://on.cypress.io/parentsuntil
|
|
92
|
+
cy.get('.clothes-nav')
|
|
93
|
+
.find('.active')
|
|
94
|
+
.parentsUntil('.clothes-nav')
|
|
95
|
+
.should('have.length', 2)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('.prev() - get previous sibling DOM element', () => {
|
|
99
|
+
// https://on.cypress.io/prev
|
|
100
|
+
cy.get('.birds').find('.active')
|
|
101
|
+
.prev().should('contain', 'Lorikeets')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('.prevAll() - get all previous sibling DOM elements', () => {
|
|
105
|
+
// https://on.cypress.io/prevall
|
|
106
|
+
cy.get('.fruits-list').find('.third')
|
|
107
|
+
.prevAll().should('have.length', 2)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('.prevUntil() - get all previous sibling DOM elements until el', () => {
|
|
111
|
+
// https://on.cypress.io/prevuntil
|
|
112
|
+
cy.get('.foods-list').find('#nuts')
|
|
113
|
+
.prevUntil('#veggies').should('have.length', 3)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('.siblings() - get all sibling DOM elements', () => {
|
|
117
|
+
// https://on.cypress.io/siblings
|
|
118
|
+
cy.get('.traversal-pills .active')
|
|
119
|
+
.siblings().should('have.length', 2)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Utilities', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/utilities')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('Cypress._ - call a lodash method', () => {
|
|
9
|
+
// https://on.cypress.io/_
|
|
10
|
+
cy.request('https://jsonplaceholder.cypress.io/users')
|
|
11
|
+
.then((response) => {
|
|
12
|
+
let ids = Cypress._.chain(response.body).map('id').take(3).value()
|
|
13
|
+
|
|
14
|
+
expect(ids).to.deep.eq([1, 2, 3])
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('Cypress.$ - call a jQuery method', () => {
|
|
19
|
+
// https://on.cypress.io/$
|
|
20
|
+
let $li = Cypress.$('.utility-jquery li:first')
|
|
21
|
+
|
|
22
|
+
cy.wrap($li).should('not.have.class', 'active')
|
|
23
|
+
cy.wrap($li).click()
|
|
24
|
+
cy.wrap($li).should('have.class', 'active')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('Cypress.Blob - blob utilities and base64 string conversion', () => {
|
|
28
|
+
// https://on.cypress.io/blob
|
|
29
|
+
cy.get('.utility-blob').then(($div) => {
|
|
30
|
+
// https://github.com/nolanlawson/blob-util#imgSrcToDataURL
|
|
31
|
+
// get the dataUrl string for the javascript-logo
|
|
32
|
+
return Cypress.Blob.imgSrcToDataURL('https://example.cypress.io/assets/img/javascript-logo.png', undefined, 'anonymous')
|
|
33
|
+
.then((dataUrl) => {
|
|
34
|
+
// create an <img> element and set its src to the dataUrl
|
|
35
|
+
let img = Cypress.$('<img />', { src: dataUrl })
|
|
36
|
+
|
|
37
|
+
// need to explicitly return cy here since we are initially returning
|
|
38
|
+
// the Cypress.Blob.imgSrcToDataURL promise to our test
|
|
39
|
+
// append the image
|
|
40
|
+
$div.append(img)
|
|
41
|
+
|
|
42
|
+
cy.get('.utility-blob img').click()
|
|
43
|
+
cy.get('.utility-blob img').should('have.attr', 'src', dataUrl)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('Cypress.minimatch - test out glob patterns against strings', () => {
|
|
49
|
+
// https://on.cypress.io/minimatch
|
|
50
|
+
let matching = Cypress.minimatch('/users/1/comments', '/users/*/comments', {
|
|
51
|
+
matchBase: true,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
expect(matching, 'matching wildcard').to.be.true
|
|
55
|
+
|
|
56
|
+
matching = Cypress.minimatch('/users/1/comments/2', '/users/*/comments', {
|
|
57
|
+
matchBase: true,
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
expect(matching, 'comments').to.be.false
|
|
61
|
+
|
|
62
|
+
// ** matches against all downstream path segments
|
|
63
|
+
matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/**', {
|
|
64
|
+
matchBase: true,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
expect(matching, 'comments').to.be.true
|
|
68
|
+
|
|
69
|
+
// whereas * matches only the next path segment
|
|
70
|
+
|
|
71
|
+
matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/*', {
|
|
72
|
+
matchBase: false,
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
expect(matching, 'comments').to.be.false
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('Cypress.Promise - instantiate a bluebird promise', () => {
|
|
79
|
+
// https://on.cypress.io/promise
|
|
80
|
+
let waited = false
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @return Bluebird<string>
|
|
84
|
+
*/
|
|
85
|
+
function waitOneSecond () {
|
|
86
|
+
// return a promise that resolves after 1 second
|
|
87
|
+
return new Cypress.Promise((resolve, reject) => {
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
// set waited to true
|
|
90
|
+
waited = true
|
|
91
|
+
|
|
92
|
+
// resolve with 'foo' string
|
|
93
|
+
resolve('foo')
|
|
94
|
+
}, 1000)
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
cy.then(() => {
|
|
99
|
+
// return a promise to cy.then() that
|
|
100
|
+
// is awaited until it resolves
|
|
101
|
+
return waitOneSecond().then((str) => {
|
|
102
|
+
expect(str).to.eq('foo')
|
|
103
|
+
expect(waited).to.be.true
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
context('Viewport', () => {
|
|
3
|
+
beforeEach(() => {
|
|
4
|
+
cy.visit('https://example.cypress.io/commands/viewport')
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
it('cy.viewport() - set the viewport size and dimension', () => {
|
|
8
|
+
// https://on.cypress.io/viewport
|
|
9
|
+
|
|
10
|
+
cy.get('#navbar').should('be.visible')
|
|
11
|
+
cy.viewport(320, 480)
|
|
12
|
+
|
|
13
|
+
// the navbar should have collapse since our screen is smaller
|
|
14
|
+
cy.get('#navbar').should('not.be.visible')
|
|
15
|
+
cy.get('.navbar-toggle').should('be.visible').click()
|
|
16
|
+
cy.get('.nav').find('a').should('be.visible')
|
|
17
|
+
|
|
18
|
+
// lets see what our app looks like on a super large screen
|
|
19
|
+
cy.viewport(2999, 2999)
|
|
20
|
+
|
|
21
|
+
// cy.viewport() accepts a set of preset sizes
|
|
22
|
+
// to easily set the screen to a device's width and height
|
|
23
|
+
|
|
24
|
+
// We added a cy.wait() between each viewport change so you can see
|
|
25
|
+
// the change otherwise it is a little too fast to see :)
|
|
26
|
+
|
|
27
|
+
cy.viewport('macbook-15')
|
|
28
|
+
cy.wait(200)
|
|
29
|
+
cy.viewport('macbook-13')
|
|
30
|
+
cy.wait(200)
|
|
31
|
+
cy.viewport('macbook-11')
|
|
32
|
+
cy.wait(200)
|
|
33
|
+
cy.viewport('ipad-2')
|
|
34
|
+
cy.wait(200)
|
|
35
|
+
cy.viewport('ipad-mini')
|
|
36
|
+
cy.wait(200)
|
|
37
|
+
cy.viewport('iphone-6+')
|
|
38
|
+
cy.wait(200)
|
|
39
|
+
cy.viewport('iphone-6')
|
|
40
|
+
cy.wait(200)
|
|
41
|
+
cy.viewport('iphone-5')
|
|
42
|
+
cy.wait(200)
|
|
43
|
+
cy.viewport('iphone-4')
|
|
44
|
+
cy.wait(200)
|
|
45
|
+
cy.viewport('iphone-3')
|
|
46
|
+
cy.wait(200)
|
|
47
|
+
|
|
48
|
+
// cy.viewport() accepts an orientation for all presets
|
|
49
|
+
// the default orientation is 'portrait'
|
|
50
|
+
cy.viewport('ipad-2', 'portrait')
|
|
51
|
+
cy.wait(200)
|
|
52
|
+
cy.viewport('iphone-4', 'landscape')
|
|
53
|
+
cy.wait(200)
|
|
54
|
+
|
|
55
|
+
// The viewport will be reset back to the default dimensions
|
|
56
|
+
// in between tests (the default can be set in cypress.config.{js|ts})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
context('Waiting', () => {
|
|
3
|
+
beforeEach(() => {
|
|
4
|
+
cy.visit('https://example.cypress.io/commands/waiting')
|
|
5
|
+
})
|
|
6
|
+
// BE CAREFUL of adding unnecessary wait times.
|
|
7
|
+
// https://on.cypress.io/best-practices#Unnecessary-Waiting
|
|
8
|
+
|
|
9
|
+
// https://on.cypress.io/wait
|
|
10
|
+
it('cy.wait() - wait for a specific amount of time', () => {
|
|
11
|
+
cy.get('.wait-input1').type('Wait 1000ms after typing')
|
|
12
|
+
cy.wait(1000)
|
|
13
|
+
cy.get('.wait-input2').type('Wait 1000ms after typing')
|
|
14
|
+
cy.wait(1000)
|
|
15
|
+
cy.get('.wait-input3').type('Wait 1000ms after typing')
|
|
16
|
+
cy.wait(1000)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('cy.wait() - wait for a specific route', () => {
|
|
20
|
+
// Listen to GET to comments/1
|
|
21
|
+
cy.intercept('GET', '**/comments/*').as('getComment')
|
|
22
|
+
|
|
23
|
+
// we have code that gets a comment when
|
|
24
|
+
// the button is clicked in scripts.js
|
|
25
|
+
cy.get('.network-btn').click()
|
|
26
|
+
|
|
27
|
+
// wait for GET comments/1
|
|
28
|
+
cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304])
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Window', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/commands/window')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('cy.window() - get the global window object', () => {
|
|
9
|
+
// https://on.cypress.io/window
|
|
10
|
+
cy.window().should('have.property', 'top')
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('cy.document() - get the document object', () => {
|
|
14
|
+
// https://on.cypress.io/document
|
|
15
|
+
cy.document().should('have.property', 'charset').and('eq', 'UTF-8')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('cy.title() - get the title', () => {
|
|
19
|
+
// https://on.cypress.io/title
|
|
20
|
+
cy.title().should('include', 'Kitchen Sink')
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import checkType from '../../packages/Tool/checkType/checkType'
|
|
2
|
+
|
|
3
|
+
describe('检查类型函数', () => {
|
|
4
|
+
it('测试[]是数组', () => {
|
|
5
|
+
expect(checkType([]).isArray()).to.equal(true)
|
|
6
|
+
})
|
|
7
|
+
it('测试[1, 2, 3]是数组', () => {
|
|
8
|
+
expect(checkType([1, 2, 3]).isArray()).to.equal(true)
|
|
9
|
+
})
|
|
10
|
+
it('测试11不是数组', () => {
|
|
11
|
+
expect(checkType(11).isArray()).to.equal(false)
|
|
12
|
+
})
|
|
13
|
+
it('测试{}不是数组', () => {
|
|
14
|
+
expect(checkType({}).isArray()).to.equal(false)
|
|
15
|
+
})
|
|
16
|
+
it('测试11是数值', () => {
|
|
17
|
+
expect(checkType(11).isNumber()).to.equal(true)
|
|
18
|
+
})
|
|
19
|
+
it('测试\'11\'不是数值', () => {
|
|
20
|
+
expect(checkType('11').isNumber()).to.equal(false)
|
|
21
|
+
})
|
|
22
|
+
it('测试[]不是数值', () => {
|
|
23
|
+
expect(checkType([]).isNumber()).to.equal(false)
|
|
24
|
+
})
|
|
25
|
+
it('测试{}是对象', () => {
|
|
26
|
+
expect(checkType({}).isObject()).to.equal(true)
|
|
27
|
+
})
|
|
28
|
+
it('测试{a: 1, b: 2}是对象', () => {
|
|
29
|
+
expect(checkType({ a: 1, b: 2 }).isObject()).to.equal(true)
|
|
30
|
+
})
|
|
31
|
+
it('测试[]不是对象', () => {
|
|
32
|
+
expect(checkType([]).isObject()).to.equal(false)
|
|
33
|
+
})
|
|
34
|
+
it('测试123不是对象', () => {
|
|
35
|
+
expect(checkType(123).isObject()).to.equal(false)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import compareStructures from '../../packages/Tool/compareStructures/compareStructures'
|
|
2
|
+
|
|
3
|
+
describe('比较两个变量的数据结构是否一致', () => {
|
|
4
|
+
it('测试1和2', () => {
|
|
5
|
+
expect(compareStructures(1, 2)).to.equal(true)
|
|
6
|
+
})
|
|
7
|
+
it('测试{}和{}', () => {
|
|
8
|
+
expect(compareStructures({}, {})).to.equal(true)
|
|
9
|
+
})
|
|
10
|
+
it('测试{a:1}和{a:2}', () => {
|
|
11
|
+
expect(compareStructures({ a: 1 }, { a: 2 })).to.equal(true)
|
|
12
|
+
})
|
|
13
|
+
it('测试{a:1}和{b:1}', () => {
|
|
14
|
+
expect(compareStructures({ a: 1 }, { b: 1 })).to.equal(false)
|
|
15
|
+
})
|
|
16
|
+
it('测试{a:1}和{a:{a:1}}', () => {
|
|
17
|
+
expect(compareStructures({ a: 1 }, { a: { a: 1 } })).to.equal(false)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import moneyFormat from '../../packages/Tool/moneyFormat/moneyFormat'
|
|
2
|
+
|
|
3
|
+
describe('金额格式化函数', () => {
|
|
4
|
+
it('测试千分位', () => {
|
|
5
|
+
expect(moneyFormat(123456)).to.equal('123,456')
|
|
6
|
+
})
|
|
7
|
+
it('测试小数位超出两位', () => {
|
|
8
|
+
expect(moneyFormat(1.2358)).to.equal('1.24')
|
|
9
|
+
})
|
|
10
|
+
it('测试小数位不足两位', () => {
|
|
11
|
+
expect(moneyFormat(1.2)).to.equal('1.2')
|
|
12
|
+
})
|
|
13
|
+
it('测试小数位末尾为0', () => {
|
|
14
|
+
expect(moneyFormat(1.20)).to.equal('1.2')
|
|
15
|
+
})
|
|
16
|
+
it('测试参数为字符串格式', () => {
|
|
17
|
+
expect(moneyFormat('123456')).to.equal('123,456')
|
|
18
|
+
})
|
|
19
|
+
it('测试0.00', () => {
|
|
20
|
+
expect(moneyFormat(0.00)).to.equal('0')
|
|
21
|
+
})
|
|
22
|
+
it('测试千分位加小数位', () => {
|
|
23
|
+
expect(moneyFormat(123456.789)).to.equal('123,456.79')
|
|
24
|
+
})
|
|
25
|
+
it('测试不要千分位', () => {
|
|
26
|
+
expect(moneyFormat(123456.789, false)).to.equal('123456.79')
|
|
27
|
+
})
|
|
28
|
+
it('测试保留三位小数', () => {
|
|
29
|
+
expect(moneyFormat(123456.7892, true, 3)).to.equal('123,456.789')
|
|
30
|
+
})
|
|
31
|
+
it('测试保留0位小数', () => {
|
|
32
|
+
expect(moneyFormat(123456.7892, true, 0)).to.equal('123,457')
|
|
33
|
+
})
|
|
34
|
+
it('测试不要千分位加保留0位小数', () => {
|
|
35
|
+
expect(moneyFormat(123456.7892, false, 0)).to.equal('123457')
|
|
36
|
+
})
|
|
37
|
+
it('测试金钱符', () => {
|
|
38
|
+
expect(moneyFormat(123456.7892, true, 2, { moneySymbol: '$' })).to.equal('$123,456.79')
|
|
39
|
+
})
|
|
40
|
+
it('测试末尾补到2位零', () => {
|
|
41
|
+
expect(moneyFormat(123456.7, true, 2, { repairZero: 2 })).to.equal('123,456.70')
|
|
42
|
+
})
|
|
43
|
+
it('测试保留4位小数并末尾补到8位零', () => {
|
|
44
|
+
expect(moneyFormat(123456.76671, true, 4, { repairZero: 8 })).to.equal('123,456.76670000')
|
|
45
|
+
})
|
|
46
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// ***********************************************
|
|
3
|
+
// This example commands.ts shows you how to
|
|
4
|
+
// create various custom commands and overwrite
|
|
5
|
+
// existing commands.
|
|
6
|
+
//
|
|
7
|
+
// For more comprehensive examples of custom
|
|
8
|
+
// commands please read more here:
|
|
9
|
+
// https://on.cypress.io/custom-commands
|
|
10
|
+
// ***********************************************
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
// -- This is a parent command --
|
|
14
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
// -- This is a child command --
|
|
18
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
// -- This is a dual command --
|
|
22
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
23
|
+
//
|
|
24
|
+
//
|
|
25
|
+
// -- This will overwrite an existing command --
|
|
26
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
27
|
+
//
|
|
28
|
+
// declare global {
|
|
29
|
+
// namespace Cypress {
|
|
30
|
+
// interface Chainable {
|
|
31
|
+
// login(email: string, password: string): Chainable<void>
|
|
32
|
+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
33
|
+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
34
|
+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
// }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
+
<title>Components App</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div data-cy-root></div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/component.ts is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
|
21
|
+
|
|
22
|
+
import { mount } from 'cypress/vue'
|
|
23
|
+
|
|
24
|
+
// Augment the Cypress namespace to include type definitions for
|
|
25
|
+
// your custom command.
|
|
26
|
+
// Alternatively, can be defined in cypress/support/component.d.ts
|
|
27
|
+
// with a <reference path="./component" /> at the top of your spec.
|
|
28
|
+
declare global {
|
|
29
|
+
namespace Cypress {
|
|
30
|
+
interface Chainable {
|
|
31
|
+
mount: typeof mount
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Cypress.Commands.add('mount', mount)
|
|
37
|
+
|
|
38
|
+
// Example use:
|
|
39
|
+
// cy.mount(MyComponent)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/e2e.ts is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type cy = any
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'cypress'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
e2e: {
|
|
5
|
+
setupNodeEvents (on, config) {
|
|
6
|
+
// implement node event listeners here
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
component: {
|
|
11
|
+
devServer: {
|
|
12
|
+
framework: 'vue',
|
|
13
|
+
bundler: 'vite'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|