<commit_before>import path from 'path';
import expect from 'expect';
import posthtml from 'posthtml';
import proxyquire from 'proxyquire';
import Promise from 'bluebird';

const mfs = {
  _files: {},

  readFileSync(filePath) {
    return this._files[filePath];
  },

  writeFileSync(filePath, content) {
    const fullPath = path.resolve(filePath);
    this._files[fullPath] = content;
  }
};

const extend = proxyquire('../src', {
  fs: mfs
}).default;

describe('Extend', () => {
  beforeEach(() => {
    mfs._files = {};
  });

  it('should render default block\'s content if layout is not extended', () => {
    return init('<html><block name="content">content</block></html>')
      .then(html => expect(html).toBe('<html>content</html>'));
  });

  it('should extend layout', () => {
    mfs.writeFileSync('./layout.html', `
            <head><block name="head">head</block></head>
            <body><block name="body">body</block></body>
            <sidebar><block name="sidebar"></block></sidebar>
            <div><block name="ad">ad</block></div>
            <footer><block name="footer">footer</block></footer>
        `);

    return init(`
            <extends src="layout.html">
                <block name="ad"></block><commit_msg>test: fix require extend<commit_after>import path from 'path';
import expect from 'expect';
import posthtml from 'posthtml';
import proxyquire from 'proxyquire';
import Promise from 'bluebird';

const mfs = {
  _files: {},

  readFileSync(filePath) {
    return this._files[filePath];
  },

  writeFileSync(filePath, content) {
    const fullPath = path.resolve(filePath);
    this._files[fullPath] = content;
  }
};

const extend = proxyquire('../src', {
  fs: mfs
});

describe('Extend', () => {
  beforeEach(() => {
    mfs._files = {};
  });

  it('should render default block\'s content if layout is not extended', () => {
    return init('<html><block name="content">content</block></html>')
      .then(html => expect(html).toBe('<html>content</html>'));
  });

  it('should extend layout', () => {
    mfs.writeFileSync('./layout.html', `
            <head><block name="head">head</block></head>
            <body><block name="body">body</block></body>
            <sidebar><block name="sidebar"></block></sidebar>
            <div><block name="ad">ad</block></div>
            <footer><block name="footer">footer</block></footer>
        `);

    return init(`
            <extends src="layout.html">
                <block name="ad"></block>
{'fraction_non_alphanumeric': 0.19047619047619047, 'fraction_numerical': 0.0, 'mean_word_length': 3.2016806722689077, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 71, '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': '454654', 'n_tokens_mistral': 756, 'n_tokens_neox': 741, 'n_words': 155}