Skip to content

Commit

Permalink
fix(get-proto-data): revert throw when undefined __protoData
Browse files Browse the repository at this point in the history
  • Loading branch information
vinz243 committed Apr 20, 2018
1 parent 659845d commit 5556d35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/getProtoData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default function getProtoData(
rels: [],
views: []
}
} else {
throw new Error(`Object ${wrapped} has no __protoData`)
}
}

Expand Down
20 changes: 20 additions & 0 deletions test/integration/views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ describe('views', () => {
expect(docs).toHaveLength(0)
})

test('creates views on a new database when querying keys', async () => {
const prefix = Date.now().toString(26) + '_'

const factory = (name: string) =>
new PouchDB(prefix + name, { adapter: 'memory' })

const docs = await Track.queryKeys(factory, TrackViews.ByAlbum)
expect(docs).toHaveLength(0)
})

test('creates views on a new database when querying keys ids', async () => {
const prefix = Date.now().toString(26) + '_'

const factory = (name: string) =>
new PouchDB(prefix + name, { adapter: 'memory' })

const docs = await Track.queryKeysIDs(factory, TrackViews.ByAlbum)
expect(docs).toEqual({})
})

test('query by view', async () => {
const docs = await Track.queryDocs(
factory,
Expand Down

0 comments on commit 5556d35

Please sign in to comment.