<commit_before>import { expect } from 'chai'
import pagination from '../../../src/api/utils/pagination'

describe('api/utils/pagination.js', () => {

  it('should create only self link', () => {
    const page = 1
    const itemsPerPage = 5
    const totalItems = 1

    const { self, next, previous } = pagination(page, itemsPerPage, totalItems,
      `/api/v1/posts`)

    expect(self).to.match(/(?=.*page\[number\]\=1)(?=.*page\[size\]\=5).*$/)
    expect(next).to.be.undefined
    expect(previous).to.be.undefined
  })
  
  it('should create only self and next links', () => {
    const page = 1
    const itemsPerPage = 5
    const totalItems = 10
    
    const { self, next, previous } = pagination(page, itemsPerPage, totalItems, 
      `/api/v1/posts`)
    
    expect(self).to.match(/(?=.*page\[number\]\=1)(?=.*page\[size\]\=5).*$/)
    expect(next).to.match(/(?=.*page\[number\]\=2)(?=.*page\[size\]\=5).*$/)
    expect(previous).to.be.undefined
  })
  
  it('should create only self and previous links', () => {
    const page = 3
    const itemsPerPage = 5
    const totalItems = 11
    
    const { self, next, previous } = pagination(page, itemsPerPage, totalItems,
      `/api/v1/posts?page[number]=${page}`)
    
    expect(self).to.match(/(?=.*page\[number\]\=3)(?=.*page\[size\]\=5).*$/)
    expect(next).to.be.undefined
    expect(previous).to.match(/(?=.*page\[number\]\=2)(?=.*page\[size\]\=5).*$/)
  })
  
  it('should create self, next and previous links', () => {
    const page = 2 
    const itemsPerPage = 5
    const totalItems = 15
    
    const { self, next, previous } = pagination(page, itemsPerPage, totalItems,
      `/api/v1/posts?page[number]=${page}`)
      
    expect(self).to.match(/(?=.*page\[number\]\=2)(?=.*page\[size\]\=5).*$/)
    expect(next).to.match(/(?=.*page\[number\]\=3)(?=.*page\[size\]\=5).*$/)
    expect(previous).t.match(/(?=.*page\[number\]\=1)(?=.*page\[size\]\=5).*$/)
  })
})
<commit_msg>Fix test<commit_after>import { expect } from 'chai'
import pagination from '../../../src/api/utils/pagination'

describe('api/utils/pagination.js', () => {

  it('should create only self link', () => {
    const page = 1
    const itemsPerPage = 5
    const totalItems = 1

    const { self, next, previous } = pagination(page, itemsPerPage, totalItems,
      `/api/v1/posts`)

    expect(self).to.match(/(?=.*page\[number\]\=1)(?=.*page\[size\]\=5).*$/)
    expect(next).to.be.undefined
    expect(previous).to.be.undefined
  })
  
  it('should create only self and next links', () => {
    const page = 1
    const itemsPerPage = 5
    const totalItems = 10
    
    const { self, next, previous } = pagination(page, itemsPerPage, totalItems, 
      `/api/v1/posts`)
    
    expect(self).to.match(/(?=.*page\[number\]\=1)(?=.*page\[size\]\=5).*$/)
    expect(next).to.match(/(?=.*page\[number\]\=2)(?=.*page\[size\]\=5).*$/)
    expect(previous).to.be.undefined
  })
  
  it('should create only self and previous links', () => {
    const page = 3
    const itemsPerPage = 5
    const totalItems = 11
    
    const { self, next, previous } = pagination(page, itemsPerPage, totalItems,
      `/api/v1/posts?page[number]=${page}`)
    
    expect(self).to.match(/(?=.*page\[number\]\=3)(?=.*page\[size\]\=5).*$/)
    expect(next).to.be.undefined
    expect(previous).to.match(/(?=.*page\[number\]\=2)(?=.*page\[size\]\=5).*$/)
  })
  
  it('should create self, next and previous links', () => {
    const page = 2 
    const itemsPerPage = 5
    const totalItems = 15
    
    const { self, next, previous } = pagination(page, itemsPerPage, totalItems,
      `/api/v1/posts?page[number]=${page}`)
      
    expect(self).to.match(/(?=.*page\[number\]\=2)(?=.*page\[size\]\=5).*$/)
    expect(next).to.match(/(?=.*page\[number\]\=3)(?=.*page\[size\]\=5).*$/)
    expect(previous).to.match(/(?=.*page\[number\]\=1)(?=.*page\[size\]\=5).*$/)
  })
})

{'fraction_non_alphanumeric': 0.238851870835469, 'fraction_numerical': 0.017939518195797026, 'mean_word_length': 2.8720238095238093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6412845', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1421, 'n_words': 231}