<commit_before>var key = "<KEY>",
    mode = "local",
    apiFactory = function(mode) {
        switch (mode) {
            case "local":
                return new SNDAPI({
                    key                : key,
                    signatureServiceUrl: "http://localhost:8081/sts/signature",
                    prefixUrl          : "http://127.0.0.1:8081/news/v2/"
                });
            case "beta":
                return  new SNDAPI({
                    key                : key,
                    signatureServiceUrl: "http://apitestbeta3.medianorge.no/sts/signature",
                    prefixUrl          : "http://apitestbeta3.medianorge.no/news/v2/"
                });
            case "production":
                return new new SNDAPI({
                    key: key
                });
        }
        throw new Exception("unknown mode, use 'local', 'beta' or 'production', ok?");
    },
    api = apiFactory(mode);

api.init();

QUnit.module("sndapi.js", {
    setup: function() {
        // this.xhr = fake_xhr;
        // var requests = this.requests = [];

        // this.xhr.onCreate = function (xhr) {
        //     requests.push(xhr);
        // };
    },

    teardown: function() {
        //this.xhr.restore();
    }
});
QUnit.config.testTimeout = 20000;

test("refresh timer initializes", function(assert) {
    assert.ok(api.getState().tokenTimerIsSet, "token timer is set");
});
<commit_msg>tests: falling back to beta server if local isn't up<commit_after>var key = "<KEY>",
    mode = "local",
    apiFactory = function(mode) {
        switch (mode) {
            case "local":
                return new SNDAPI({
                    key                : key,
                    signatureServiceUrl: "http://localhost:8081/sts/signature",
                    prefixUrl          : "http://127.0.0.1:8081/news/v2/"
                });
            case "beta":
                return  new SNDAPI({
                    key                : key,
                    signatureServiceUrl: "http://apitestbeta3.medianorge.no/sts/signature",
                    prefixUrl          : "http://apitestbeta3.medianorge.no/news/v2/"
                });
            case "production":
                return new new SNDAPI({
                    key: key
                });
        }
        throw new Exception("unknown mode, use 'local', 'beta' or 'production', ok?");
    },
    api = apiFactory(mode);

api.init()
    .fail(function() {
        console.log("You have not started the local server (for example with `gulp serve`), testing with beta API");
        api = apiFactory("beta");
        api.init();
    });
QUnit.module("sndapi.js");
QUnit.config.testTimeout = 20000;

test("refresh timer initializes", function(assert) {
    assert.ok(api.getState().tokenTimerIsSet, "token timer is set");
});

{'fraction_non_alphanumeric': 0.13558131366350545, 'fraction_numerical': 0.016157358623112048, 'mean_word_length': 1.4679376083188909, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1751661', 'n_tokens_mistral': 825, 'n_tokens_neox': 773, 'n_words': 171}