-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvariants.ts
More file actions
87 lines (83 loc) · 3.02 KB
/
variants.ts
File metadata and controls
87 lines (83 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { expect } from "chai"
import { Stack } from "../../types/stack";
import { variantEntry, variantEntry2 } from "./mock/variants";
var tokenUID = ''
export function createVariant(stack: Stack) {
describe('Variant create', () => {
test('Create a variant', done => {
stack.VariantGroup('variant_group_uid').variants().create({variantEntry})
.then((response) => {
expect(response.name).to.be.equal(variantEntry.name)
expect(response.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
})
}
export function queryVariant(stack: Stack) {
describe('Query variants', () => {
test('Get all variants', done => {
stack.VariantGroup('variant_group_uid').variants().query().find()
.then((response) => {
response.items.forEach((variant) => {
expect(variant.name).to.be.not.equal(null)
expect(variant.uid).to.be.not.equal(null)
})
done()
})
.catch(done)
})
test('Get variants from name', done => {
stack.VariantGroup(tokenUID).variants().query({query: {name: variantEntry2[0].name}})
.find()
.then((response) => {
response.items.forEach((variant_groups) => {
expect(variant_groups.name).to.be.equal(variantEntry.name)
expect(variant_groups.uid).to.be.not.equal(null)
})
done()
})
.catch(done)
})
})
}
export function variant(stack: Stack) {
describe('Variants operations', () => {
test('Fetch variant', done => {
stack.variantGroup(tokenUID).variant(variantEntry.uid)
.fetch()
.then((response) => {
expect(response.name).to.be.equal(variantEntry.name)
expect(response.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
test('Fetch and update a Variant from uid', done => {
stack.variantGroup(tokenUID).variant('uid')
.fetch()
.then((response) => {
response.name = 'Update Variant name'
return response.update()
})
.then((response) => {
expect(response.name).to.be.equal('Update Variant name')
expect(response.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
test('Update variant from uid', done => {
const variants = stack.variantGroup(tokenUID).variant(variantEntry.uid)
Object.assign(variants, variantEntry)
variants.update()
.then((response) => {
expect(response.name).to.be.equal(variantEntry.name)
expect(response.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
})
}