-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlocale-test.js
More file actions
144 lines (132 loc) · 4.22 KB
/
locale-test.js
File metadata and controls
144 lines (132 loc) · 4.22 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { expect } from 'chai'
import { describe, it, setup } from 'mocha'
import { jsonReader } from '../utility/fileOperations/readwrite'
import { contentstackClient } from '../utility/ContentstackClient.js'
let client = {}
describe('Locale api Test', () => {
setup(() => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
})
it('should add a language English - Austria', done => {
makeLocale()
.create({ locale: { code: 'en-at' } })
.then((locale) => {
expect(locale.code).to.be.equal('en-at')
expect(locale.name).to.be.equal('English - Austria')
expect(locale.fallback_locale).to.be.equal('en-us')
expect(locale.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
it('should add a language Hindi - India', done => {
makeLocale()
.create({ locale: { code: 'hi-in' } })
.then((locale) => {
expect(locale.code).to.be.equal('hi-in')
expect(locale.name).to.be.equal('Hindi - India')
expect(locale.fallback_locale).to.be.equal('en-us')
expect(locale.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
it('should add a language Marathi - India with Fallback en-at', done => {
makeLocale()
.create({ locale: { code: 'mr-in', fallback_locale: 'en-at' } })
.then((locale) => {
expect(locale.code).to.be.equal('mr-in')
expect(locale.name).to.be.equal('Marathi - India')
expect(locale.fallback_locale).to.be.equal('en-at')
expect(locale.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
it('should get a all languages', done => {
makeLocale()
.query()
.find()
.then((locales) => {
locales.items.forEach((locale) => {
expect(locale.code).to.be.not.equal(null)
expect(locale.name).to.be.not.equal(null)
expect(locale.uid).to.be.not.equal(null)
})
done()
})
.catch(done)
})
it('should query a language Hindi - India', done => {
makeLocale()
.query({ query: { name: 'Hindi - India' } })
.find()
.then((locales) => {
locales.items.forEach((locale) => {
expect(locale.code).to.be.equal('hi-in')
expect(locale.name).to.be.equal('Hindi - India')
expect(locale.fallback_locale).to.be.equal('en-us')
expect(locale.uid).to.be.not.equal(null)
})
done()
})
.catch(done)
})
it('should get a language Hindi - India', done => {
makeLocale('hi-in')
.fetch()
.then((locale) => {
expect(locale.code).to.be.equal('hi-in')
expect(locale.name).to.be.equal('Hindi - India')
expect(locale.fallback_locale).to.be.equal('en-us')
expect(locale.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
it('should get and update a language Hindi - India with fallback locale en-at', done => {
makeLocale('hi-in')
.fetch()
.then((locale) => {
locale.fallback_locale = 'en-at'
return locale.update()
})
.then((locale) => {
expect(locale.code).to.be.equal('hi-in')
expect(locale.name).to.be.equal('Hindi - India')
expect(locale.fallback_locale).to.be.equal('en-at')
expect(locale.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
it('should get and update a language Hindi - India with fallback locale en-us', done => {
makeLocale('hi-in')
.fetch()
.then((locale) => {
locale.fallback_locale = 'en-us'
return locale.update()
})
.then((locale) => {
expect(locale.code).to.be.equal('hi-in')
expect(locale.name).to.be.equal('Hindi - India')
expect(locale.fallback_locale).to.be.equal('en-us')
expect(locale.uid).to.be.not.equal(null)
done()
})
.catch(done)
})
it('should delete language: Hindi - India', done => {
makeLocale('mr-in')
.delete()
.then((data) => {
expect(data.notice).to.be.equal('Language removed successfully.')
done()
})
.catch(done)
})
})
function makeLocale (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).locale(uid)
}