Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>Settings</h1>
<script>
var switched = false;
var user = {key: 'foobar.com'};
var client = window.ld = LDClient.initialize('569f514183f2164430000004', user, {
var client = LDClient.initialize('569f514183f2164430000004', user, {
bootstrap: {
'client-side-flag': false,
'another-client-side-flag': false
Expand Down
7 changes: 4 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module.exports = function(config) {
config.set({
files: [
'src/*.js',
'test/*.js'
'test/*-test.js'
],

plugins: [
'karma-browserify',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-phantomjs-shim',
'karma-mocha',
Expand All @@ -25,10 +26,10 @@ module.exports = function(config) {

preprocessors: {
'src/*.js': ['browserify'],
'test/*.js': ['browserify']
'test/*-test*.js': ['browserify']
},

browsers: ['PhantomJS'],
browsers: ['Chrome'],

autoWatch: false,

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"karma-chai": "0.1.0",
"karma-mocha": "1.0.1",
"karma-mocha-reporter": "2.0.4",
"karma-chrome-launcher": "1.0.1",
"karma-phantomjs-launcher": "0.2.1",
"karma-phantomjs-shim": "1.1.2",
"karma-sinon": "1.0.5",
Expand Down
1 change: 0 additions & 1 deletion src/EventProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ function EventProcessor(eventsUrl) {
var processor = {};
var queue = [];
var initialFlush = true;
var flushTimeoutId;

processor.enqueue = function(event) {
queue.push(event);
Expand Down
50 changes: 50 additions & 0 deletions test/LDClient-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
var LDClient = require('../src/index');

describe('LDClient', function() {
var xhr;
var requests = [];

beforeEach(function() {
xhr = sinon.useFakeXMLHttpRequest();
xhr.onCreate = function(req) {
requests.push(req);
};
});

afterEach(function() {
requests = [];
xhr.restore();
});

it('should exist', function() {
expect(LDClient).to.exist;
});

describe('initialization', function() {
it('should trigger the ready event', function(done) {
var user = {key: 'user'};
var handleReady = sinon.spy();
var client = LDClient.initialize('UNKNOWN_ENVIRONMENT_ID', user, {
bootstrap: {}
});

client.on('ready', handleReady);

setTimeout(function() {
expect(handleReady.called).to.be.true;
done();
}, 0);
});

it('should not fetch flag settings since bootstrap is provided', function() {
var user = {key: 'user'};
var client = LDClient.initialize('UNKNOWN_ENVIRONMENT_ID', user, {
bootstrap: {}
});

var settingsRequest = requests[0];
expect(/sdk\/eval/.test(settingsRequest.url)).to.be.false;
});
});

});
3 changes: 0 additions & 3 deletions test/client.js

This file was deleted.