Skip to content

Commit

Permalink
add test for ntp api
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Mar 22, 2019
1 parent c6786a4 commit de36c33
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
52 changes: 52 additions & 0 deletions components/test/brave_new_tab_ui/api_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* global describe, it */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

import { getGridSites } from '../../brave_new_tab_ui/api'

describe('new tab api tests', () => {
const defaultState = {
topSites: [],
ignoredTopSites: [],
pinnedTopSites: [],
bookmarks: {}
}
describe('getGridSites', () => {
it('allows http sites', () => {
const url = 'http://cezaraugusto.net'
const newState = {
...defaultState,
topSites: [
{ url }
]
}
const assertion = getGridSites(newState, true)
expect(assertion[0]).toBe(newState.topSites[0])
expect(assertion[0].url).toBe(url)
})
it('allows https sites', () => {
const url = 'https://cezaraugusto.net'
const newState = {
...defaultState,
topSites: [
{ url }
]
}
const assertion = getGridSites(newState, true)
expect(assertion[0]).toBe(newState.topSites[0])
expect(assertion[0].url).toBe(url)
})
it('do not allow the default chrome topSites url', () => {
const url = 'https://chrome.google.com/webstore?hl=en'
const newState = {
...defaultState,
topSites: [
{ url }
]
}
const assertion = getGridSites(newState, true)
expect(assertion[0]).toBe(undefined)
})
})
})
13 changes: 13 additions & 0 deletions components/test/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ export const getMockChrome = () => {
},
braveRewards: {
getPublisherData: (id: number, url: string, favicon: string) => undefined
},
extension: {
inIncognitoContext: new ChromeEvent()
},
topSites: {
get: function () {
return
}
},
bookmarks: {
search: function () {
return
}
}
}
}
Expand Down

0 comments on commit de36c33

Please sign in to comment.