Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
o-seliuchenko committed Nov 12, 2020
1 parent d20096d commit e8c7c52
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion spec/accommodation/list/HappyPathSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Accommodation Listing', () => {
it('- should get accom listing', () => {
const expected = `${endpoints.temporaryAccommodation}?pageSize=10&index=0`
expect(ajaxGetStub.calledAfter(browserLoadingStub)).toBeTruthy()
expect(ajaxGetStub.getCalls()[0].args[0]).toEqual(expected)
expect(ajaxGetStub.getCalls()[0].args[0].slice(0, ajaxGetStub.getCalls()[0].args[0].indexOf('&unique'))).toEqual(expected)
})

it('- should get cities', () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/charter-pledges/ListCharterPledgesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('List Charter Pledges', () => {

it('should retrieve non-approved pledges by default', () => {
const expected = `${endpoints.charterPledges}?isApproved=false&pageSize=10&index=0`
expect(ajaxGetStub.getCalls()[0].args[0]).toEqual(expected)
expect(ajaxGetStub.getCalls()[0].args[0].slice(0, ajaxGetStub.getCalls()[0].args[0].indexOf('&unique'))).toEqual(expected)
})

it('should set url to supporter full name', () => {
Expand Down
4 changes: 3 additions & 1 deletion spec/service-providers/SearchFromQuerystringSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ describe('Service Providers - search - from querystring', () => {
.split('&')
.forEach((kv) => {
const [key, value] = kv.split('=')
actual[key] = value
if (key !== 'unique') {
actual[key] = value
}
})
expect(actual).toEqual(expected)
})
Expand Down
8 changes: 6 additions & 2 deletions spec/service-providers/SearchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ describe('Service Providers - search', () => {
.split('&')
.forEach((kv) => {
const [key, value] = kv.split('=')
actual[key] = value
if (key !== 'unique') {
actual[key] = value
}
})
expect(actual).toEqual(expected)
})
Expand Down Expand Up @@ -130,7 +132,9 @@ describe('Service Providers - search', () => {
.split('&')
.forEach((kv) => {
const [key, value] = kv.split('=')
actual[key] = value
if (key !== 'unique') {
actual[key] = value
}
})
expect(actual).toEqual(expected)
})
Expand Down
7 changes: 3 additions & 4 deletions spec/service-providers/ServiceProvidersListingSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Service Providers', () => {

it('should retrieve service providers from api', () => {
var endpoint = `${endpoints.getServiceProvidersv3}?pageSize=10&index=0`
expect(stubbedApi.firstCall.args[0]).toEqual(endpoint)
expect(stubbedApi.firstCall.args[0].slice(0, stubbedApi.firstCall.args[0].indexOf('&unique'))).toEqual(endpoint)
})

it('should tell user loaded', () => {
Expand Down Expand Up @@ -119,9 +119,8 @@ describe('Service Providers', () => {
})

it('- should retrieve new page', () => {
var endpoint = `${endpoints.getServiceProvidersv3}?pageSize=10&index=20`
var apiCalledWithExpectedArgs = stubbedApi.withArgs(endpoint).calledOnce
expect(apiCalledWithExpectedArgs).toBeTruthy()
var expected = `${endpoints.getServiceProvidersv3}?pageSize=10&index=20`
expect(stubbedApi.lastCall.args[0].slice(0, stubbedApi.lastCall.args[0].indexOf('&unique'))).toEqual(expected)
})
})
})
5 changes: 4 additions & 1 deletion src/js/models/ListingBaseViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ function ListingBaseViewModel () {
const getUrl = self.buildGetUrl(existingFilters)
browser.pushHistory({}, '', `?${getUrl.qs}`)

// We generate this for retrieving the not cached item
let syntaxSugar = new Date().getTime()

ajax
.get(getUrl.fullUrl)
.get(getUrl.fullUrl + `&unique=${syntaxSugar}`)
.then(function (result) {
browser.loaded()
self.pagination.updateData(result.data)
Expand Down
2 changes: 1 addition & 1 deletion src/js/models/content-pages/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Model = function () {
self.itemCreated = ko.observable(false)
self.title = ko.observable()
self.body = ko.observable()
self.tags = ko.observable('')
self.tags = ko.observable()
self.sortPosition = ko.observable()
self.parentScenarios = ko.observableArray([])
self.parentScenarioId = ko.observable()
Expand Down
2 changes: 1 addition & 1 deletion src/js/models/content-pages/listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Model = function () {
}
self.filters = [
{ key: 'type', setValue: (vm, value) => vm.typeToFilterOn(value), getValue: (vm) => vm.typeToFilterOn(), isSet: (val) => val !== undefined && val.length > 0 },
{ key: 'searchTerm', setValue: (vm, value) => vm.nameToFilterOn(value), getValue: (vm) => vm.nameToFilterOn(), isSet: (val) => val !== undefined && val.length > 0 }
{ key: 'searchTerm', setValue: (vm, value) => vm.nameToFilterOn(value), getValue: (vm) => { return vm.nameToFilterOn() ? vm.nameToFilterOn().trim() : vm.nameToFilterOn() }, isSet: (val) => val !== undefined && val.length > 0 }
]
self.baseUrl = self.endpointBuilder.contentPages().build()

Expand Down

0 comments on commit e8c7c52

Please sign in to comment.