Skip to content

Commit

Permalink
Set the TLS cookie rather than stubbing getCookie (#1754)
Browse files Browse the repository at this point in the history
Set the TLS cookie rather than stubbing getCookie
  • Loading branch information
chao-xian authored Jun 17, 2019
2 parents 3140b81 + bc1b0d7 commit 477b4bd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions spec/javascripts/surveys-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,23 +573,27 @@ describe('Surveys', function () {
})

describe('currentTlsVersion', function() {
afterEach(function() {
window.GOVUK.setCookie('TLSversion', null)
})

it('returns an empty string when the cookie returns null', function () {
spyOn(GOVUK, 'getCookie').and.returnValue(null)
window.GOVUK.setCookie('TLSversion', null)
expect(surveys.currentTlsVersion()).toBe('')
})

it('returns an empty string when the cookie returns "unknown"', function () {
spyOn(GOVUK, 'getCookie').and.returnValue("unknown")
window.GOVUK.setCookie('TLSversion', "unknown")
expect(surveys.currentTlsVersion()).toBe('')
})

it('returns the correct version when the cookie returns a valid value"', function () {
spyOn(GOVUK, 'getCookie').and.returnValue("TLSv1.1")
window.GOVUK.setCookie('TLSversion', "TLSv1.1")
expect(surveys.currentTlsVersion()).toBe(1.1)
})

it('returns an empty string when the TLS version is malformed"', function () {
spyOn(GOVUK, 'getCookie').and.returnValue("TLSvabcd11123")
window.GOVUK.setCookie('TLSversion', "TLSvabcd11123")
expect(surveys.currentTlsVersion()).toBe('')
})
})
Expand Down

0 comments on commit 477b4bd

Please sign in to comment.