<commit_before>'use strict';

var SolveBio = require('../src/solvebio');

describe('Tests fitlers', function() {
  beforeEach(function() {
    SolveBio.init({
      debug: true,
      accessToken: 'fakeToken'
    });
  });

  it('should create a single filter', function() {
    var filter = SolveBio.Filter({
      rcv_accession: 'RCV000058095'
    });
    expect(filter.filters).toEqual(['rcv_accession', 'RCV000058095']);
  });

  it('should create an and filter', function() {
    var filter = SolveBio.Filter({
      rcv_accession: 'RCV000058095',
      clinical_significance: 'Pathogenic'
    });
    expect(filter.filters).toEqual({
      and: [
        ['rcv_accession', 'RCV000058095'],
        ['clinical_significance', 'Pathogenic']
      ]
    });
  });

  it('should combine filters with all()', function() {
    var filter1 = SolveBio.Filter({
      gene_symbol: 'BRCA1'
    });
    var filter2 = SolveBio.Filter({
      clinical_significance: 'Pathogenic'
    });
    expect(filter1.and(filter2).filters).toEqual({
      and: [
        ['gene_symbol', 'BRCA1'],
        ['clinical_significance', 'Pathogenic']
      ]
    });
  });

  it('should combine filters with or()', function() {
    var filter1 = SolveBio.Filter({
      gene_symbol: 'BRCA1'
    });
    var filter2 = SolveBio.Filter({
      gene_symbol: 'BRCA2'
    });
    expect(filter1.or(filter2).filters).toEqual({
      or: [
        ['gene_symbol', 'BRCA1'],
        ['gene_symbol', 'BRCA2']
      ]
    });
  });

  it('should inverse a filter', function() {
    var filter = SolveBio.Filter({
      gene_symbol: 'BRCA1'
    });
    expect(filter.not().filters).toEqual({
      not: ['gene_symbol', 'BRCA1']
    });
  });<commit_msg>added a test for nested filters<commit_after>'use strict';

var SolveBio = require('../src/solvebio');

describe('Tests fitlers', function() {
  beforeEach(function() {
    SolveBio.init({
      debug: true,
      accessToken: 'fakeToken'
    });
  });

  it('should create a single filter', function() {
    var filter = SolveBio.Filter({
      rcv_accession: 'RCV000058095'
    });
    expect(filter.filters).toEqual(['rcv_accession', 'RCV000058095']);
  });

  it('should create an and filter', function() {
    var filter = SolveBio.Filter({
      rcv_accession: 'RCV000058095',
      clinical_significance: 'Pathogenic'
    });
    expect(filter.filters).toEqual({
      and: [
        ['rcv_accession', 'RCV000058095'],
        ['clinical_significance', 'Pathogenic']
      ]
    });
  });

  it('should combine filters with all()', function() {
    var filter1 = SolveBio.Filter({
      gene_symbol: 'BRCA1'
    });
    var filter2 = SolveBio.Filter({
      clinical_significance: 'Pathogenic'
    });
    expect(filter1.and(filter2).filters).toEqual({
      and: [
        ['gene_symbol', 'BRCA1'],
        ['clinical_significance', 'Pathogenic']
      ]
    });
  });

  it('should combine filters with or()', function() {
    var filter1 = SolveBio.Filter({
      gene_symbol: 'BRCA1'
    });
    var filter2 = SolveBio.Filter({
      gene_symbol: 'BRCA2'
    });
    expect(filter1.or(filter2).filters).toEqual({
      or: [
        ['gene_symbol', 'BRCA1'],
        ['gene_symbol', 'BRCA2']
      ]
    });
  });

  it('should support nested filters', function() {
    var filter1 = SolveBio.Filter({
      gene_symbol: 'BRCA1'
    });
    var filter2 = SolveBio.Filter({
      gene_symbol: 'BRCA2'
    });
    var filter3 = SolveBio.Filter({
      clinical_significance: 'Pathogenic'
    });
    expect(filter1.or(filter2.and(filter3)).filters).toEqual({
      or: [
        ['gene_symbol', 'BRCA1'],
        {
          and: [
            ['gene_symbol', 'BRCA2'],
            ['clinical_significance', 'Pathogenic']
          ]
        }
      ]
    });
  });

  it('should inverse a filter', function() {
    var filter = SolveBio.Filter({
      gene_symbol: 'BRCA1'
    });
    expect(filter.not().filters).toEqual({
      not: ['gene_symbol', 'BRCA1']
    });
  });
{'fraction_non_alphanumeric': 0.16658329164582292, 'fraction_numerical': 0.028514257128564282, 'mean_word_length': 2.6755514705882355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4634798', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1284, 'n_words': 242}