-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathLicenseCode.js
66 lines (63 loc) · 3.35 KB
/
LicenseCode.js
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
module.exports = {
'Check if the p-tag with the class license-text is present': function(browser) {
browser
.init()
.assert.elementPresent('.control-label > span')
.click('.control-label > span')
.assert.elementPresent('.pagination-next')
.click('.pagination-next')
.assert.elementPresent('.select > select')
.click('.select')
.click('option[value="CC BY-SA 4.0"]')
.assert.elementPresent('.pagination-next')
.click('.pagination-next')
.assert.elementPresent('p[class="license-text"]')
},
'Check if the links in the license code redirects properly': function(browser) {
browser
.setValue('input[placeholder="Jane Doe"]', 'Jane Doe')
.setValue('input[placeholder="www.author.com"]', 'www.author.com')
.setValue('input[placeholder="This work"]', 'This work')
.setValue('input[placeholder="www.author.com/work.jpg"]', 'www.author.com/work.jpg')
.assert.elementPresent('p[class="license-text"] a')
.getAttribute('p > span > a:nth-child(1)', 'href', function(result) {
const urlString = result.value.split('/').slice(3).join('/')
this.assert.equal(urlString, 'www.author.com/work.jpg')
})
.getAttribute('p > span > a:nth-child(2)', 'href', function(result) {
const urlString = result.value.split('/').slice(3).join('/')
this.assert.equal(urlString, 'www.author.com')
})
.getAttribute('p > span > a:nth-child(4)', 'href', function(result) {
const urlString = result.value.split('/').slice(3).join('/')
this.assert.equal(urlString, 'licenses/by-sa/4.0/?ref=ccchooser')
})
},
'Check if the text is displayed under the print attribution': function(browser) {
browser
.click('nav > ul > li:nth-child(2) > a')
.assert.elementPresent('p[class="license-text"]')
.assert.elementPresent('#attribution-text > p > span:nth-child(1)')
.assert.elementPresent('#attribution-text > p > span:nth-child(2)')
},
// Tests for the text under the "Plain Text"
'Check if the work in plain text is displayed': function(browser) {
browser
.click('nav > ul > li:nth-child(2) > a')
.expect.element('#attribution-text > p > span:nth-child(1) > span:nth-child(1)').text.to.equal('This work')
},
'Check if the license in plain text is displayed': function(browser) {
browser
.expect.element('#attribution-text > p > span:nth-child(1) > span:nth-child(4)').text.to.equal('CC BY-SA 4.0')
},
'Check if the author-name in plain text is displayed': function(browser) {
browser
.expect.element('#attribution-text > p > span:nth-child(1) > span:nth-child(2) > span').text.to.equal('Jane Doe')
},
'Check if the license-details in plain text are displayed': function(browser) {
browser
.click('nav > ul > li:nth-child(2) > a')
.assert.elementPresent('#attribution-text > p > span:nth-child(2)')
.expect.element('#attribution-text > p > span:nth-child(2)').text.to.equal('. To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/4.0')
}
}