-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
132 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { MongoClient } from '../../src'; | ||
import { Db, DbOptions } from '../../src/db'; | ||
import { ReadPreference } from '../../src/read_preference'; | ||
|
||
describe('class Db', function () { | ||
describe('secondaryOk', function () { | ||
const client = new MongoClient('mongodb://localhost:27017'); | ||
const legacy_secondary_ok = 'slaveOk'; | ||
const secondary_ok = 'secondaryOk'; | ||
|
||
it('should be false when readPreference is Primary', function () { | ||
const options: DbOptions = { readPreference: ReadPreference.PRIMARY }; | ||
const mydb = new Db(client, 'mydb', options); | ||
|
||
expect(mydb).property(secondary_ok).to.be.false; | ||
expect(mydb).property(legacy_secondary_ok).to.be.false; | ||
}); | ||
|
||
it('should be true when readPreference is Primary Preferred', function () { | ||
const options: DbOptions = { readPreference: ReadPreference.PRIMARY_PREFERRED }; | ||
const mydb = new Db(client, 'mydb', options); | ||
|
||
expect(mydb).property(secondary_ok).to.be.true; | ||
expect(mydb).property(legacy_secondary_ok).to.be.true; | ||
}); | ||
|
||
it('should be true when readPreference is Secondary', function () { | ||
const options: DbOptions = { readPreference: ReadPreference.SECONDARY }; | ||
const mydb = new Db(client, 'mydb', options); | ||
|
||
expect(mydb).property(secondary_ok).to.be.true; | ||
expect(mydb).property(legacy_secondary_ok).to.be.true; | ||
}); | ||
|
||
it('should be true when readPreference is Secondary Preferred', function () { | ||
const options: DbOptions = { readPreference: ReadPreference.SECONDARY_PREFERRED }; | ||
const mydb = new Db(client, 'mydb', options); | ||
|
||
expect(mydb).property(secondary_ok).to.be.true; | ||
expect(mydb).property(legacy_secondary_ok).to.be.true; | ||
}); | ||
|
||
it('should be true when readPreference is Nearest', function () { | ||
const options: DbOptions = { readPreference: ReadPreference.NEAREST }; | ||
const mydb = new Db(client, 'mydb', options); | ||
|
||
expect(mydb).property(secondary_ok).to.be.true; | ||
expect(mydb).property(legacy_secondary_ok).to.be.true; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters